﻿<%@ Page Title="" Language="C#" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>
    <script src="../../Scripts/jquery.alerts.js" type="text/javascript"></script>
    <link href="../../Content/Css/jquery.alerts.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript">
        $(document).ready(function () {

            jQuery('#list2').jqGrid({
                url: '/Administration/NewsLetter/GetPartnerList/',
                datatype: 'JSON',
                mtype: 'GET',
                colNames: ['Stt', 'ID', 'Doanh Nghiệp', 'Email'],
                colModel: [{ name: 'No', index: 'No', align: 'center', width: 20 },
                           { name: 'ID', index: 'ID', align: 'center', width: 50, hidden: true },
                           { name: 'PartnerName', index: 'PartnerName', align: 'left', width: 300, sortable: false },
                           { name: 'Email', index: 'Email', align: 'center', width: 350, sortable: false}],
                rowNum: 999999999,
                sortname: '',
                sortorder: 'desc',
                multiselect: true,
                viewrecords: true,
                width: '700', height: '500',
                imgpath: '/scripts/grid/themes/basic/images',
                loadui: 'block',
                loadComplete: function () { }
            });
            $("#btnSend").click(function () {
                var id = <%=ViewData["NewsLetterID"] %>;
                var pid = JS_LIB.getSelectedIDs('#list2', 'ID');
                var other_email = $("#ExternalEmail").val();
                var isSendEmailReg = $('input[name=IsSendToRegisterMail]').is(':checked');
                if(pid=="" && other_email=="" && !isSendEmailReg)
                {
                    jAlert("Vui lòng nhập hoặc chọn email cần gửi","TSV-thesinhvien.com.vn");
                    return;
                }
                jConfirm("Bạn có chắc chắn muốn gửi bản tin này?","Confirm",function(r){
                    if(r)
                        window.location="/Administration/NewsLetter/SendNewsLetter/?id=" + id + "&ArrID=" + pid + "&Other=" + other_email + "&isSendEmailRegister=" + isSendEmailReg;  
                });
                    
               

            });
        });
       
    </script>
   

    <%using (Html.BeginForm("", "", FormMethod.Post, new { id = "sendEmailForm", @class = "form" }))
  {%>
    <table width="100%" border="0" cellpadding="0" cellspacing="0" class="edit">
     <tr>
        <td class="label">
            Check vào nếu 
        </td>
        <td class="input">
            <% Response.Write(Html.CheckBox("IsSendToRegisterMail",false));
               Response.Write("<label for=\"IsSendToRegisterMail\"> muốn gửi cho danh sách email đăng ký nhận bản tin</label>&nbsp;");
            %>
        </td>
    </tr>
    <tr>
        <td class="label">
          Email khác:
        </td>
        <td class="input">
            Nhiều email cách nhau bằng dấu ";"<br />
            <% 
                Response.Write(Html.TextArea("ExternalEmail", "", new {@style = "width:100%" }));
                
            %>
        </td>
    </tr>
    <tr>
        <td colspan="2">
            
            <fieldset>
                <legend>Danh sách email các doanh nghiệp đã hợp tác</legend>
                <div class="clist" >

                    <table id="list2" class="scroll">
                    </table>
                    
                </div>
                 
            </fieldset>
            
        </td>
    </tr>
    <tr>
        
        <td align="center" colspan="2">
            <input type="button" value="Gửi bản tin" alt="" id="btnSend"/>
            <input type="button" value="Đóng lại" alt="" onclick="JS_LIB.closePopup()" />
        </td>
    </tr>
</table>
<% } %>


